﻿#region Usings

using PolyGameEngine.GamePieces.Common;
using PolyGameEngine.Tools;

using FarseerPhysics.Dynamics;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion


namespace PolyMorph.CustomGamePieces
{
    public class Finnish : SensorForceTile
    {
        public Finnish(PhysicsGame PhysicsGame, World World, Material Material, Texture2D FinTexture, Vector2 Position, int SaveLineIndex) :
            base(PhysicsGame, World, Material, FinTexture, 1, Position, 0, 0, 1, SaveLineIndex, "Finnish",0)
        { }
        bool Done = false;
        public override void Effect()
        {
            if (!LevelEditor.Level.Singleton.editorMode)
            {
                if (Vector2.Distance(GamePieceInEffect.position, position) < 5 && !Done)
                {
                    LevelComplete();
                }
            }
            else
                Done = true;
        }

        public override void HandleDefaultAfterEffect(Fixture ThisFixture, Fixture OtherFixture)
        {
            Done = false;
            base.HandleDefaultAfterEffect(ThisFixture, OtherFixture);
        }

        public void LevelComplete()
        {
            Done = true;
            AudioMan.PlayCue("Finish");
            LevelEditor.Level.loadNext();
            Done = true; ;
        }
    }
}
